using System.Drawing;

namespace OpenComposite.Base.Designer
{
	public class RectangleConnector : Connector
	{
		#region Initialization
		public RectangleConnector()
		{
			init();
		}
		private void init()
		{
			this.BeginUpdate();

			//this.Name = "rectangleConnector" + GetCount(typeof(RectangleConnector));
			this.Text = "";

			this.Size = new System.Drawing.Size(10, 10);
			this.Font = new Font(FontFamily.GenericSerif, 12, FontStyle.Bold);

			this.BackColor = Color.WhiteSmoke;

			_format = new StringFormat(StringFormat.GenericDefault);
			_format.Alignment = StringAlignment.Center;
			_format.LineAlignment = StringAlignment.Center;

			this.EndUpdate();
		}
		#endregion

		#region Public Members

		#region Properties (Overrided)
		public override bool CanFocused
		{
			get
			{
				return false;
			}
		}
		public override bool CanMove
		{
			get
			{
				return false;
			}
		}
		public override bool CanResize
		{
			get
			{
				return false;
			}
		}
		public override bool CanSelect
		{
			get
			{
				return false;
			}
		}
		public override bool NoClip
		{
			get
			{
				return true;
			}
		}
		#endregion

		#region Methods (Overrided)
		public override void Dispose()
		{
			dispose(_format);

			base.Dispose();
		}

		public override void PaintBackground(System.Windows.Forms.PaintEventArgs pe)
		{
			Rectangle rect = this.GetPaintBounds();
			pe.Graphics.DrawRectangle(Pens.Blue, rect);
			pe.Graphics.FillRectangle(this.BackBrush, rect);
		}
		public override void Paint(System.Windows.Forms.PaintEventArgs pe)
		{
			Rectangle rect = this.GetPaintClientArea();
			pe.Graphics.DrawString(this.Text, this.Font, Brushes.Black, rect, _format);
		}
		#endregion

		#endregion

		#region Private Members

		#region Variables
		private StringFormat _format;
		#endregion

		#endregion
	}
}
